'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let dictionaryService = require('../../../service/system/dictionaryService.js');
let logger = require('../../../util/LoggerUtil').logger('dictionaryController.js');

/**
 * 系统设置-系统参数管理—页面
 */
module.exports.dictionaryPage = function () {
    let response = new Response();
    response.render('back/system/dictionary/dictionary');//html路径
    this.resolve(response);
};

/**
 * 系统设置-系统参数管理——列表
 */
module.exports.dictionaryList = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await dictionaryService.dictionaryList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};

/**
 * 系统设置-系统参数管理——字典分组数据
 */
module.exports.dictionarygroupList = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await dictionaryService.dictionarygroupList(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/*系统参数管理-新增页面-确认按钮*/
module.exports.dictionaryAdd = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await dictionaryService.dictionaryAdd(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/*系统参数管理-修改页面-确认按钮*/
module.exports.dictionaryModify = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await dictionaryService.dictionaryModify(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/*系统参数管理-删除按钮*/
module.exports.dictionaryDelete = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await dictionaryService.dictionaryDelete(this, params.dictId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
